package cn.qyd.javaarray;

import org.checkerframework.checker.units.qual.A;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

/**
 * @author 邱运铎
 * @date 2024-03-15 21:46
 */
public class towNUmDemo {
    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,4,5,6};
        int target = 9;
        int[] result = new int[2];
        HashMap<Integer,Integer> hashMap = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            if (hashMap.containsKey(arr[i])) {
                result[0] = i;
                result[1] = hashMap.get(arr[i]);
                break;
            }
            hashMap.put(target - arr[i],i);
        }

        System.out.println(Arrays.toString(result));
    }

    public int[] test() {
        return new int[]{1,2};
    }
}
